<template>
  <div class="app-container">
    <el-dialog
      :title="title"
      :visible.sync="openDetail"
      @close="cancel"
      width="600px"
      append-to-body
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="auto" style="width: 500px;">
        <el-form-item label="解析方式" prop="analysisWay">
          <el-input v-model="form.analysisWay" placeholder="请输入解析方式" />
        </el-form-item>

        <el-form-item label="解析类型" prop="analysisType">
          <el-radio-group v-model="form.analysisType">
            <el-radio :label="'1'">国标</el-radio>
            <el-radio :label="'2'">欧标</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="指标名称" prop="tagName">
          <el-input v-model="form.tagName" placeholder="请输入指标名称" />
        </el-form-item>
        <el-form-item label="指标取值列" prop="tagColumn">
          <el-input-number v-model="form.tagColumn" placeholder="请输入指标取值列" />
        </el-form-item>
        <el-form-item label="指标取值行 " prop="tagRow">
          <el-input-number v-model="form.tagRow" placeholder="请输入指标取值行"></el-input-number>
        </el-form-item>
 
        <!-- <el-row>
          <el-col :span="24">
            <el-form-item label="说明" prop="routeDesc">
              <el-input v-model="form.routeDesc" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
  
  <script>
import {
  updateAnalysis,
  delAnalysis,
  addAnalysis
} from "@/api/mes/md/debugConfig";
export default {
  data() {
    return {
      openDetail: false,
      title: "新增调试机参数明细",
      // 表单参数
      form: {},
      loading: false,
      routeproductbomList: [],
      issueId: null,
      // 选中数组
      ids: [],
      //物料编码
      itemCodes: [],
      measureCodes: [],
      //批量打印
      selectionList: [],
      rules: {
        analysisType: [
          { required: true, message: "解析类型不能为空", trigger: "change" },
        ],
        tagName: [
          { required: true, message: "指标名称不能为空", trigger: "blur" },
        ],
        tagColumn: [
          { required: true, message: "指标取值列不能为空", trigger: "blur" },
        ],
        tagRow: [
          { required: true, message: "指标取值行不能为空", trigger: "blur" },
        ],
      }
    };
  },
  dicts: ["mes_order_status"],
  methods: {
    //初始化函数
    init(row, data) {
      console.log(row, data,"子组件的row");
      this.openDetail = true;
      this.$nextTick(() => {
        let query ={}
        query.equipmentId = row.id;
        query.analysisWay = "Excel";
        this.form["analysisWay"]= "Excel";
        Object.assign(this.form, query);
        Object.assign(this.form, data);
      })
      console.log(this.form,"=========form-======");
    },

    // 取消按钮
    cancel() {
      this.openDetail = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        equipmentId: null,
        analysisWay: null,
        tagColumn: null,
        tagRow: null,
        tagName: null
      };
      this.autoGenFlag = false;
      this.resetForm("form");
    },
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateAnalysis(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.openDetail = false;
              this.$emit("parentList");
            });
          } else {
            addAnalysis(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.openDetail = false;
              this.$emit("parentList");
            });
          }
        }
      });
    }
  }
};
</script>
  <style rel="stylesheet/scss" lang="scss" scoped>
.app-container ::v-deep .el-drawer__header {
  padding-top: 10px !important;
  padding-bottom: 5px !important;
  margin-bottom: 10px !important;
}

.bg-purple {
  display: flex;
  align-items: center;
  span:nth-child(1) {
    display: inline-block;
    // width: 100px;
    margin-right: 10px;
    white-space: nowrap;
    line-height: 30px;
  }
}
.titleDiv {
  font-weight: 700 !important;
  font-size: 20px;
}
</style>
  